package com.example.testapp.activity.activity.study;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.Window;

import com.example.testapp.activity.http.RetryNetwork;
import com.example.testapp.activity.listener.PwdErrorListener;
import com.example.testapp.activity.ui.Task;
import com.example.testapp.activity.util.ThreadPoolManager;

/**
 * Created by l on 2016/11/1.
 */

public class SuperFragmentActivity extends FragmentActivity implements RetryNetwork, PwdErrorListener {
    private static final String TAG = "SuperFragmentActivity";

    protected boolean isActive = false;
    protected Context mContext;
    protected ThreadPoolManager mThreadPoolManager;
    /**
     * 碎片管理器
     */
    protected FragmentManager fmm;
    /**
     * 当前最后执行的线程任务,task的ID属性可以用于判断线程启动的先后
     */
    protected Task lastTask = new Task(0) {
        @Override
        public void run() {

        }
    };

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = this;
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        isActive = true;

        fmm = getSupportFragmentManager();
        mThreadPoolManager = ThreadPoolManager.getInstance();
    }

    @Override
    protected void onResume() {
        super.onResume();
        isActive = true;
    }

    @Override
    protected void onPause() {
        super.onPause();
        isActive = false;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        isActive = false;
    }

    public boolean getActive() {
        return isActive;
    }

    @Override
    public void retry() {

    }

    @Override
    public void netError() {

    }

    @Override
    public void pwdError() {

    }
}
